#define _CRT_SECURE_NO_WARNINGS 
using namespace std;
#include <stdio.h>
#include <math.h>
#include<algorithm>
struct yzc {
	int x, y, z;
}s[50001];
bool cmp(yzc a, yzc b)
{
	return a.z < b.z;
}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d%d", &s[i].x, &s[i].y, &s[i].z);
	}
	sort(s + 1, s + n + 1, cmp);
	double len = 0;
	for (int i = 2; i <= n; i++)
	{
		len += sqrt(pow(s[i].x - s[i -1].x, 2) + pow(s[i].y - s[i -1].y, 2) + pow(s[i].z - s[i -1].z, 2));
	}
	printf("%.3lf", len);
	return 0;
}